package com.example.emvoider.model;

import com.example.emvoider.base.BaseModel;
import com.example.emvoider.bean.Bean;
import com.example.emvoider.bean.NaviBean;
import com.example.emvoider.net.ApiService;
import com.example.emvoider.net.ResultCallBack;
import com.example.emvoider.util.HttpUtil;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.ResourceSubscriber;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 阿炜啊 on 2020/7/10.
 */

public class MainModel extends BaseModel {

    public void getData(final ResultCallBack<NaviBean> callBack) {

        addDisposable(
                HttpUtil.getInstance()
                .getWanService()
                .getNavi()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new ResourceSubscriber<NaviBean>() {
                    @Override
                    public void onNext(NaviBean naviBean) {
                        callBack.onSuccess(naviBean);
                    }

                    @Override
                    public void onError(Throwable t) {
                        callBack.onFail(t.toString());
                    }

                    @Override
                    public void onComplete() {

                    }
                })

        );


    }

}
